<?php
date_default_timezone_set("PRC");
header('Content-Type:text/html;charset=utf-8');
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header('Access-Control-Allow-Headers:x-requested-with,content-type');

$url = "http://localhost:9898";
class MyPdo{
    private $link;
    public function __construct($host,$dbname,$username,$password,$utf){
        $this->link = new PDO("mysql:$host;port=3306;dbname=$dbname","$username","$password");
        $this->link->query("set name $utf");
    }
    public function query($sql){
        return $this->link->query($sql);
    }
    public function getOne($sql){
        return $this->query($sql)->fetch();
    }
    public function getAll($sql){
        return $this->query($sql)->fetchAll();
    }
}

try{
    $pdo = new MyPdo("localhost","toutiao","root","root","utf-8");
}catch(PDOException $err){
    echo $err->getMessage();
}
?>